<script setup lang="ts">
import { ref, onMounted } from "vue";
import router from "@/router";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { useRoute } from "vue-router";
import { getDictList } from "@/api/dict";

const multiTagsStore = useMultiTagsStoreHook();
const route = useRoute();

let form = ref({
  stocktakingType: "",
  warehouseName: "",
  stocktakingCode: "",
  leaderUserName: "",
  memo: ""
});
const adjustTypeList = ref([]);

const goBack = () => {
  multiTagsStore.handleTags("splice", route.path);
  router.back();
};

const setForm = (opt: {}) => {
  form.value = opt || {};
};

const getAdjustTypeList = async () => {
  const res = await getDictList({
    dictCode: "WAREHOUSE_INVENTORY_ADJUST_TYPE"
  });
  adjustTypeList.value = res.data;
};

onMounted(() => {
  getAdjustTypeList();
});

defineExpose({
  getForm: () => form.value,
  setForm
});
</script>

<template>
  <div class="applyForm">
    <div class="flex items-center justify-between flex-row pb-[16px]">
      <p class="text-[16px] font-bold">调整信息管理</p>
      <el-button @click="goBack"
        ><svg-icon name="rollback" size="16" />&nbsp;返回</el-button
      >
    </div>
    <el-descriptions class="mb-[-12px]">
      <el-descriptions-item label="调整类型：">
        {{ adjustTypeList.find(val => val.dictLabelValue == form.adjustType)?.dictLabelName }}
      </el-descriptions-item>
      <el-descriptions-item label="仓库名称：">
        {{ form.warehouseName }}
      </el-descriptions-item>
      <el-descriptions-item label="调整单号：">
        {{ form.adjustCode }}
      </el-descriptions-item>
      <el-descriptions-item label="备注：">
        {{ form.memo }}
      </el-descriptions-item>
    </el-descriptions>
  </div>
</template>

<style scoped lang="scss">
.applyForm {
  overflow: hidden;
}
</style>
